package com.linjiang.design.strategy.v1;

/**
 * 僵尸游戏例子
 */
public class ZombieTest {
    public static void main(String[] args) {
        NormalZombie normalZombie = new NormalZombie();
        FlagZombie flagZombie = new FlagZombie();
        XxxHeadZombie xxxHeadZombie = new XxxHeadZombie();

        normalZombie.display();
        normalZombie.move();
        normalZombie.attack();


        flagZombie.display();
        flagZombie.move();
        flagZombie.attack();

        xxxHeadZombie.display();
        xxxHeadZombie.move();
        xxxHeadZombie.attack();
    }
}

abstract class AbstractZombie{

    //抽象方法，具体由子类实现
    public abstract void display();

    public void attack(){
        System.out.println("哎。。。");
    }

    public void move(){
        System.out.println("一步一步移动。");
    }
}

class NormalZombie extends AbstractZombie{

    @Override
    public void display() {
        System.out.println("我是普通僵尸");
    }
}

class FlagZombie extends AbstractZombie{

    @Override
    public void display() {
        System.out.println("我是旗手僵尸");
    }
}

class BigHeadZombie extends AbstractZombie{

    @Override
    public void display() {
        System.out.println("我是大头僵尸");
    }

    @Override
    public void attack() {
        System.out.println("头撞");
    }
}

//具备大头僵尸的攻击方式，移动方式和外观有自己的实现
class XxxHeadZombie extends BigHeadZombie{

    @Override
    public void display() {
        System.out.println("我是自定义僵尸");
    }

    @Override
    public void move() {
        System.out.println("大步移动");
    }
}



